package com.wn.ziroom.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.wn.ziroom.entity.vo.ProductionVo;

import java.math.BigDecimal;


import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 *
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Getter
@Setter
@TableName("t_cart_item")
public class CartItem {

    /**
     * ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;
    private ProductionVo productionVo;
    private Integer buyCount;
    private BigDecimal subTotal;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setProductionVo(ProductionVo productionVo) {
        this.productionVo = productionVo;
    }

    public void setSubTotal(BigDecimal subTotal) {
        this.subTotal = subTotal;
    }

    public ProductionVo getProductionVo() {
        return productionVo;
    }

    public void setBook(ProductionVo productionVo) {
        this.productionVo = productionVo;
    }

    public Integer getBuyCount() {
        return buyCount;
    }

    public void setBuyCount(Integer buyCount) {
        this.buyCount = buyCount;
    }

    public BigDecimal getSubTotal() {
        BigDecimal productionPrice = productionVo.getProductionPrice();
        BigDecimal buyCount = new BigDecimal(this.buyCount);
        subTotal = productionPrice.multiply(buyCount);
        return subTotal;
    }

    public CartItem(ProductionVo productionVo, Integer buyCount) {
        this.productionVo = productionVo;
        this.buyCount = buyCount;
    }



    public CartItem() {
    }

    @Override
    public String toString() {
        return "CartItem{" +
                "productionVo=" + productionVo +
                ", buyCount=" + buyCount +
                ", subTotal=" + subTotal +
                '}';
    }
}
